package com.kkb.staticproxy;

import com.kkb.service.IService;

public class ProxyTranService implements IService {

    private IService service;

    @Override
    public void add(int id, String name) {

    }

    @Override
    public boolean update(int num) {
        return false;
    }

    public ProxyTranService(IService service) {
        this.service = service;
    }

    @Override
    public void add() {
        try {
            System.out.println("开始事务");
            service.add();//核心业务
            System.out.println("提交事务");
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("回滚事务");
        }

    }
}
